package org.hbkj.springbootmybatis.service;

import org.hbkj.springbootmybatis.dao.AdminDao;
import org.hbkj.springbootmybatis.entity.AdminDo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminService {

    @Autowired
    private AdminDao adminDao;

    /**
     * 管理员登录校验
     * @param username 用户名
     * @param password 密码
     * @return 登录成功返回管理员实体，失败返回 null
     */
    public AdminDo adminLogin(String username, String password) {
        AdminDo adminDo = adminDao.findAdminByUsername(username);
        if (adminDo != null && adminDo.getPassword().equals(password)) {
            // 移除敏感信息
            adminDo.setPassword(null);
            return adminDo;
        }
        return null;
    }
}